//
//  TabarViewController.m
//  MyLottery
//
//  Created by wpapple on 16/5/24.
//  Copyright © 2016年 wpapple. All rights reserved.
//

#import "TabarViewController.h"

#import "HistoryViewController.h"
#import "SettingViewController.h"
#import "HallViewController.h"
#import "DiscoveryViewController.h"
#import "ArgnaViewController.h"

#import "TabBarView.h"

@interface TabarViewController ()<TabBarViewDelegate>

@end

@implementation TabarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    TabBarView *tabbar = [[TabBarView alloc]init];
    
    tabbar.frame = self.tabBar.bounds;
    
    tabbar.delegate = self;
    
    [tabbar setBackgroundColor:[UIColor blackColor]];
    
    [self.tabBar addSubview:tabbar];
    
    [self addMyChildViewController:@"Hall"];
    [self addMyChildViewController:@"Argna"];
    [self addMyChildViewController:@"Discovery"];
    [self addMyChildViewController:@"History"];
    [self addMyChildViewController:@"Setting"];
    

}

-(void)addMyChildViewController:(NSString *)name
{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:name bundle:nil];
    
    UIViewController * rootVC = [sb instantiateInitialViewController];
    
    [self addChildViewController:rootVC];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)tabbar:(TabBarView *)tabbar fromTag:(NSInteger)from toTag:(NSInteger)to
{
    self.selectedIndex = to;
}

@end
